#include "LivePanelWidget.h"
#include "ui_LivePanelWidget.h"
#include "UnLivePage.h"
#include "AudioLivePage.h"
#include "VideoLivePage.h"
LivePanelWidget::LivePanelWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LivePanelWidget)
{
    ui->setupUi(this);

    InitPages();
}

LivePanelWidget::~LivePanelWidget()
{
    delete ui;
}

void LivePanelWidget::InitPages()
{
     if(nullptr == unLivePage_)
     {
         unLivePage_ = new UnLivePage(ui->stackedWidget);
         ui->stackedWidget->addWidget(unLivePage_);
     }

     if(nullptr == audioLivePage_)
     {
         audioLivePage_ = new AudioLivePage(ui->stackedWidget);
         ui->stackedWidget->addWidget(audioLivePage_);
     }

     if(nullptr == videoLivePage_)
     {
         videoLivePage_ = new VideoLivePage(ui->stackedWidget);
         ui->stackedWidget->addWidget(videoLivePage_);
     }

     ActivePage(kUnLivePage);
}

void LivePanelWidget::ActivePage(LivePageType type)
{
    ui->stackedWidget->setCurrentIndex(type);
}

QWidget* LivePanelWidget::GetWidget(LivePageType type)
{
    switch (type) {
    case kUnLivePage:
        return unLivePage_;
    case kAudioLivePage:
        return audioLivePage_;
    case kVideoLivePage:
        return videoLivePage_;
    default:
        return nullptr;
    }
}
